﻿CREATE TABLE [dbo].[LogisticsPackageNote] (
    [Id]                INT            IDENTITY (1, 1) NOT NULL,
    [PackageId]         INT            NOT NULL,
	[CustomerId]         INT            NOT NULL,
    [Note]              NVARCHAR (MAX) NOT NULL,
	[TypeId]            INT            NOT NULL,
    [DisplayToCustomer] BIT            NOT NULL,
    [CreatedOnUtc]      DATETIME       NOT NULL,
    PRIMARY KEY CLUSTERED ([Id] ASC),
    CONSTRAINT [PackageNote_Package] FOREIGN KEY ([PackageId]) REFERENCES [dbo].[LogisticsPackage] ([Id]) ON DELETE CASCADE,
	CONSTRAINT [PackageNote_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE
);

GO
CREATE NONCLUSTERED INDEX [IX_PackageNote_PackageId]
    ON [dbo].[LogisticsPackageNote]([PackageId] ASC);

CREATE NONCLUSTERED INDEX [IX_PackageNote_CustomerId]
    ON [dbo].[LogisticsPackageNote]([CustomerId] ASC);